package com.netString;

public class TestSubString {

	public static void main(String[] args)
	{
		String str = "hello my hello hello my is";
		String str1 = "my";
		
		
        System.out.println("count of string my  " + count(str,str1));
	}

	private static int count(String str, String str1) 
	{
		String term = str;
		
		int cnt = 0;
		
		while(term.length()>0)
		{
			int index = term.indexOf(str1);
			if(index == -1)
			{
				break;
			}
			
			term = term.substring(index +str1.length(), term.length());
			cnt++;
		}
		
		
		return cnt;
	}

}
